/*
 *    Alliciga's Process Partner Project
 * 
 *  Copyright (C) 2006-2011 Alliciga <alliciga@users.sourceforge.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 */

#include "../include/SimpleThread.h"

SimpleThread::SimpleThread()
{
	closing = false;
	pThread = NULL;
}

bool SimpleThread::run()
{
	//boost::thread_resource_error Exception will be throw if failed.
	pThread = new boost::thread(boost::bind(&SimpleThread::MainLoop,this));
	return true;
}

SimpleThread::~SimpleThread()
{
	if(pThread)
		delete pThread;
}

void SimpleThread::close()
{
	closing = true;
}

void SimpleThread::join()
{
	pThread->join();
}

void SimpleThread::MainLoop()
{
	while(!closing)
	{
		sleep(1);
	}
}
